<template>
	<view>
		<page-head :title="title"></page-head>
		<view class="content">
			<homePage v-if="page_code=='home'"></homePage>
			<addressbook v-if="page_code=='addressbook'"></addressbook>
			<setting v-if="page_code=='setting'"></setting>
		</view>
		<footerNav></footerNav>
	</view>
</template>

<script>
	import homePage from "./pages/main_page.vue";
	import addressbook from "./pages/addressbook.vue";
	import setting from "./pages/setting.vue";
	import footerNav from "../../components/footer/footer_nav.vue";
	export default {
		data() {
			return {
				title: ''
			}
		},
		components: {
			homePage,
			addressbook,
			setting,
			footerNav
		},
		
		computed: {
			page_code() {
				console.log("index.vue page_code index:" + this.$store.state.footer_store.now_page_index + " footLength:" +this.$store.state.footer_store.footer_nav.length )
			    this.setNaviBarTitle(this.$store.state.footer_store.footer_nav[this.$store.state.footer_store.now_page_index].name);
				
				if (this.$store.state.footer_store.now_page_index == (this.$store.state.footer_store.footer_nav.length -1)) {
					uni.reLaunch({
						url: '../login/login',
						complete: () => {  this.$store.state.footer_store.now_page_index = 0; } 
					});
				}else {
					return this.$store.state.footer_store.footer_nav[this.$store.state.footer_store.now_page_index].name_code;	
				}
				
			}
		},
		onLoad() {

		},
		methods: {
			open_loading() {
				this.$loading()
			},
			setNaviBarTitle(title) {
				uni.setNavigationBarTitle({
					title: title
				})
			}
		}
		
	}
</script>

<style>
	.content {
		text-align: center;
		height: 400upx;
	}

	.logo {
		height: 200upx;
		width: 200upx;
		margin-top: 200upx;
	}

	.title {
		font-size: 36upx;
		color: #8f8f94;
	}
</style>
